package ua.kharkiv.karimov.knure.SummaryTask1;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map.Entry;

import ua.kharkiv.karimov.knure.SummaryTask1.Airplanes.*;
import ua.kharkiv.karimov.knure.SummaryTask1.client.Client;
import ua.kharkiv.karimov.knure.SummaryTask1.client.ClientAirControl;
import ua.kharkiv.karimov.knure.SummaryTask1.server.Server;

class test1 {
	static {
		System.out.println("test1");
	}
}
/**
 * This class for the testing
 * The server controls the aircraft - receives data from them, and they may send different requests. A server also handles requests from the client. Basic commands:
 * <li> weight_capacity - Calculate the total capacity and capacity. </li>
 * <li> get fuelkm xy - Find plane in the company, corresponding to a specified range of parameters in fuel consumption. x y range </li>
 * @author Karimov
 */
public class Program {

	static int i = 0;

	public static void main(String[] args) throws InterruptedException {
		new Thread() {
			public void run() {
				try {
					new Server();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}.start();

		new Thread() {
			public void run() {
				new Client();
			}
		}.start();
		new Thread() {
			public void run() {
				try {
					sleep(1000);
				} catch (InterruptedException e1) {
					e1.printStackTrace();
				}
				Craft plane1 = new Airliner(183, 162, 59, 70, 20, "Boing 747-100",
						"B747B", 955, 170, 340, 452, 20.1);
				Craft plane2 = new Airliner(183, 180, 59, 70, 20, "Boing 747-100",
						"B747B", 955, 158, 412, 452, 17.5);
				Airport from = null;
				Airport to = null;
				try {
					
					from = new Airport(new Coord(0, 0, 0), "Borispol");
					to = new Airport(new Coord(100, 100, 10), "Chuguev");
					plane1.setAirportFrom(from);
					plane1.setAirportTo(to);
					plane1.setCoord(new Coord(0, 0, 0));
					new ClientAirControl(plane1);
					try {
						sleep(1000);
					} catch (InterruptedException e1) {
						e1.printStackTrace();
					}
					plane1 = plane1.getModelCopy("B747AA");
					plane1.setAirportFrom(to);
					plane1.setAirportTo(from);
					plane1.setCoord(new Coord(0, 0, 0));
					new ClientAirControl(plane1);
					try {
						sleep(1000);
					} catch (InterruptedException e1) {
						e1.printStackTrace();
					}
					plane2.setAirportFrom(to);
					plane2.setAirportTo(from);
					plane2.setCoord(new Coord(0, 0, 0));
					new ClientAirControl(plane2);
					} catch (Exception e) {
					e.printStackTrace();
				}
			}

		}.start();

	}

}
